//
//  ZCProjectdetailsModel.m
//
//  Created by   on 15/10/8
//  Copyright (c) 2015 __MyCompanyName__. All rights reserved.
//

#import "ZCProjectdetailsModel.h"


NSString *const kZCProjectdetailsModelRank = @"rank";
NSString *const kZCProjectdetailsModelLocation = @"location";
NSString *const kZCProjectdetailsModelInstitutionid = @"institutionid";
NSString *const kZCProjectdetailsModelCode = @"code";
NSString *const kZCProjectdetailsModelMid = @"mid";
NSString *const kZCProjectdetailsModelCtime = @"ctime";
NSString *const kZCProjectdetailsModelBrand = @"brand";
NSString *const kZCProjectdetailsModelEmoney = @"emoney";
NSString *const kZCProjectdetailsModelPackageid = @"packageid";
NSString *const kZCProjectdetailsModelPdname = @"pdname";
NSString *const kZCProjectdetailsModelFromtype = @"fromtype";
NSString *const kZCProjectdetailsModelState = @"state";
NSString *const kZCProjectdetailsModelTestreportid = @"testreportid";
NSString *const kZCProjectdetailsModelId = @"id";
NSString *const kZCProjectdetailsModelSample = @"sample";
NSString *const kZCProjectdetailsModelSamnum = @"samnum";
NSString *const kZCProjectdetailsModelEtime = @"etime";
NSString *const kZCProjectdetailsModelThumb = @"thumb";
NSString *const kZCProjectdetailsModelPjname = @"pjname";
NSString *const kZCProjectdetailsModelFirstCategory = @"first_category";
NSString *const kZCProjectdetailsModelSecondCategory = @"second_category";
NSString *const kZCProjectdetailsModelResult = @"result";
NSString *const kZCProjectdetailsModelBtime = @"btime";
NSString *const kZCProjectdetailsModelContent = @"content";
NSString *const kZCProjectdetailsModelInstitution = @"institution";
NSString *const kZCProjectdetailsModelPackage = @"packagename";
NSString *const kZCProjectdetailsModelFinish = @"finish";
NSString *const kZCProjectdetailsModelTestreport = @"testreport";
NSString *const kZCProjectdetailsModelTestreport_jpg = @"testreport_jpg";

@interface ZCProjectdetailsModel ()

- (id)objectOrNilForKey:(id)aKey fromDictionary:(NSDictionary *)dict;

@end

@implementation ZCProjectdetailsModel

@synthesize rank = _rank;
@synthesize location = _location;
@synthesize institutionid = _institutionid;
@synthesize code = _code;
@synthesize mid = _mid;
@synthesize ctime = _ctime;
@synthesize brand = _brand;
@synthesize emoney = _emoney;
@synthesize packageid = _packageid;
@synthesize pdname = _pdname;
@synthesize fromtype = _fromtype;
@synthesize state = _state;
@synthesize testreportid = _testreportid;
@synthesize contentIdentifier = _contentIdentifier;
@synthesize sample = _sample;
@synthesize samnum = _samnum;
@synthesize etime = _etime;
@synthesize thumb = _thumb;
@synthesize pjname = _pjname;
@synthesize firstCategory = _firstCategory;
@synthesize secondCategory = _secondCategory;
@synthesize result = _result;
@synthesize btime = _btime;
@synthesize content = _content;
@synthesize institution = _institution;
@synthesize packagename = _packagename;
@synthesize finish= _finish;
@synthesize testreport_jpg = _testreport_jpg;


+ (instancetype)modelObjectWithDictionary:(NSDictionary *)dict
{
    return [[self alloc] initWithDictionary:dict];
}

- (instancetype)initWithDictionary:(NSDictionary *)dict
{
    self = [super init];
    
    // This check serves to make sure that a non-NSDictionary object
    // passed into the model class doesn't break the parsing.
    if(self && [dict isKindOfClass:[NSDictionary class]]) {
            self.rank = [self objectOrNilForKey:kZCProjectdetailsModelRank fromDictionary:dict];
            self.location = [self objectOrNilForKey:kZCProjectdetailsModelLocation fromDictionary:dict];
            self.institutionid = [self objectOrNilForKey:kZCProjectdetailsModelInstitutionid fromDictionary:dict];
            self.code = [self objectOrNilForKey:kZCProjectdetailsModelCode fromDictionary:dict];
            self.mid = [self objectOrNilForKey:kZCProjectdetailsModelMid fromDictionary:dict];
            self.ctime = [self objectOrNilForKey:kZCProjectdetailsModelCtime fromDictionary:dict];
            self.brand = [self objectOrNilForKey:kZCProjectdetailsModelBrand fromDictionary:dict];
            self.emoney = [self objectOrNilForKey:kZCProjectdetailsModelEmoney fromDictionary:dict];
            self.packageid = [self objectOrNilForKey:kZCProjectdetailsModelPackageid fromDictionary:dict];
            self.pdname = [self objectOrNilForKey:kZCProjectdetailsModelPdname fromDictionary:dict];
            self.fromtype = [[self objectOrNilForKey:kZCProjectdetailsModelFromtype fromDictionary:dict] doubleValue];
            self.state = [self objectOrNilForKey:kZCProjectdetailsModelState fromDictionary:dict];
            self.testreportid = [self objectOrNilForKey:kZCProjectdetailsModelTestreportid fromDictionary:dict];
            self.contentIdentifier = [self objectOrNilForKey:kZCProjectdetailsModelId fromDictionary:dict];
            self.sample = [self objectOrNilForKey:kZCProjectdetailsModelSample fromDictionary:dict];
            self.samnum = [self objectOrNilForKey:kZCProjectdetailsModelSamnum fromDictionary:dict];
            self.etime = [self objectOrNilForKey:kZCProjectdetailsModelEtime fromDictionary:dict];
            self.thumb = [self objectOrNilForKey:kZCProjectdetailsModelThumb fromDictionary:dict];
            self.pjname = [self objectOrNilForKey:kZCProjectdetailsModelPjname fromDictionary:dict];
            self.firstCategory = [self objectOrNilForKey:kZCProjectdetailsModelFirstCategory fromDictionary:dict];
            self.secondCategory = [self objectOrNilForKey:kZCProjectdetailsModelSecondCategory fromDictionary:dict];
            self.result = [self objectOrNilForKey:kZCProjectdetailsModelResult fromDictionary:dict];
            self.btime = [self objectOrNilForKey:kZCProjectdetailsModelBtime fromDictionary:dict];
            self.content = [self objectOrNilForKey:kZCProjectdetailsModelContent fromDictionary:dict];
            self.institution = [self objectOrNilForKey:kZCProjectdetailsModelInstitution fromDictionary:dict];
            self.packagename = [self objectOrNilForKey:kZCProjectdetailsModelPackage fromDictionary:dict];
        
            self.finish = [self objectOrNilForKey:kZCProjectdetailsModelFinish fromDictionary:dict];
        self.testreport = [self objectOrNilForKey:kZCProjectdetailsModelTestreport fromDictionary:dict];
        self.testreport_jpg = [self objectOrNilForKey:kZCProjectdetailsModelTestreport_jpg fromDictionary:dict];
    }
    
    return self;
    
}

- (NSDictionary *)dictionaryRepresentation
{
    NSMutableDictionary *mutableDict = [NSMutableDictionary dictionary];
    [mutableDict setValue:self.rank forKey:kZCProjectdetailsModelRank];
    [mutableDict setValue:self.location forKey:kZCProjectdetailsModelLocation];
    [mutableDict setValue:self.institutionid forKey:kZCProjectdetailsModelInstitutionid];
    [mutableDict setValue:self.code forKey:kZCProjectdetailsModelCode];
    [mutableDict setValue:self.mid forKey:kZCProjectdetailsModelMid];
    [mutableDict setValue:self.ctime forKey:kZCProjectdetailsModelCtime];
    [mutableDict setValue:self.brand forKey:kZCProjectdetailsModelBrand];
    [mutableDict setValue:self.emoney forKey:kZCProjectdetailsModelEmoney];
    [mutableDict setValue:self.packageid forKey:kZCProjectdetailsModelPackageid];
    [mutableDict setValue:self.pdname forKey:kZCProjectdetailsModelPdname];
    [mutableDict setValue:[NSNumber numberWithDouble:self.fromtype] forKey:kZCProjectdetailsModelFromtype];
    [mutableDict setValue:self.state forKey:kZCProjectdetailsModelState];
    [mutableDict setValue:self.testreportid forKey:kZCProjectdetailsModelTestreportid];
    [mutableDict setValue:self.contentIdentifier forKey:kZCProjectdetailsModelId];
    [mutableDict setValue:self.sample forKey:kZCProjectdetailsModelSample];
    [mutableDict setValue:self.samnum forKey:kZCProjectdetailsModelSamnum];
    [mutableDict setValue:self.etime forKey:kZCProjectdetailsModelEtime];
    [mutableDict setValue:self.thumb forKey:kZCProjectdetailsModelThumb];
    [mutableDict setValue:self.pjname forKey:kZCProjectdetailsModelPjname];
    [mutableDict setValue:self.firstCategory forKey:kZCProjectdetailsModelFirstCategory];
    [mutableDict setValue:self.secondCategory forKey:kZCProjectdetailsModelSecondCategory];
    [mutableDict setValue:self.result forKey:kZCProjectdetailsModelResult];
    [mutableDict setValue:self.btime forKey:kZCProjectdetailsModelBtime];
    [mutableDict setValue:self.content forKey:kZCProjectdetailsModelContent];

    return [NSDictionary dictionaryWithDictionary:mutableDict];
}

- (NSString *)description 
{
    return [NSString stringWithFormat:@"%@", [self dictionaryRepresentation]];
}

#pragma mark - Helper Method
- (id)objectOrNilForKey:(id)aKey fromDictionary:(NSDictionary *)dict
{
    id object = [dict objectForKey:aKey];
    return [object isEqual:[NSNull null]] ? nil : object;
}


#pragma mark - NSCoding Methods

- (id)initWithCoder:(NSCoder *)aDecoder
{
    self = [super init];

    self.rank = [aDecoder decodeObjectForKey:kZCProjectdetailsModelRank];
    self.location = [aDecoder decodeObjectForKey:kZCProjectdetailsModelLocation];
    self.institutionid = [aDecoder decodeObjectForKey:kZCProjectdetailsModelInstitutionid];
    self.code = [aDecoder decodeObjectForKey:kZCProjectdetailsModelCode];
    self.mid = [aDecoder decodeObjectForKey:kZCProjectdetailsModelMid];
    self.ctime = [aDecoder decodeObjectForKey:kZCProjectdetailsModelCtime];
    self.brand = [aDecoder decodeObjectForKey:kZCProjectdetailsModelBrand];
    self.emoney = [aDecoder decodeObjectForKey:kZCProjectdetailsModelEmoney];
    self.packageid = [aDecoder decodeObjectForKey:kZCProjectdetailsModelPackageid];
    self.pdname = [aDecoder decodeObjectForKey:kZCProjectdetailsModelPdname];
    self.fromtype = [aDecoder decodeDoubleForKey:kZCProjectdetailsModelFromtype];
    self.state = [aDecoder decodeObjectForKey:kZCProjectdetailsModelState];
    self.testreportid = [aDecoder decodeObjectForKey:kZCProjectdetailsModelTestreportid];
    self.contentIdentifier = [aDecoder decodeObjectForKey:kZCProjectdetailsModelId];
    self.sample = [aDecoder decodeObjectForKey:kZCProjectdetailsModelSample];
    self.samnum = [aDecoder decodeObjectForKey:kZCProjectdetailsModelSamnum];
    self.etime = [aDecoder decodeObjectForKey:kZCProjectdetailsModelEtime];
    self.thumb = [aDecoder decodeObjectForKey:kZCProjectdetailsModelThumb];
    self.pjname = [aDecoder decodeObjectForKey:kZCProjectdetailsModelPjname];
    self.firstCategory = [aDecoder decodeObjectForKey:kZCProjectdetailsModelFirstCategory];
    self.secondCategory = [aDecoder decodeObjectForKey:kZCProjectdetailsModelSecondCategory];
    self.result = [aDecoder decodeObjectForKey:kZCProjectdetailsModelResult];
    self.btime = [aDecoder decodeObjectForKey:kZCProjectdetailsModelBtime];
    self.content = [aDecoder decodeObjectForKey:kZCProjectdetailsModelContent];
    return self;
}

- (void)encodeWithCoder:(NSCoder *)aCoder
{

    [aCoder encodeObject:_rank forKey:kZCProjectdetailsModelRank];
    [aCoder encodeObject:_location forKey:kZCProjectdetailsModelLocation];
    [aCoder encodeObject:_institutionid forKey:kZCProjectdetailsModelInstitutionid];
    [aCoder encodeObject:_code forKey:kZCProjectdetailsModelCode];
    [aCoder encodeObject:_mid forKey:kZCProjectdetailsModelMid];
    [aCoder encodeObject:_ctime forKey:kZCProjectdetailsModelCtime];
    [aCoder encodeObject:_brand forKey:kZCProjectdetailsModelBrand];
    [aCoder encodeObject:_emoney forKey:kZCProjectdetailsModelEmoney];
    [aCoder encodeObject:_packageid forKey:kZCProjectdetailsModelPackageid];
    [aCoder encodeObject:_pdname forKey:kZCProjectdetailsModelPdname];
    [aCoder encodeDouble:_fromtype forKey:kZCProjectdetailsModelFromtype];
    [aCoder encodeObject:_state forKey:kZCProjectdetailsModelState];
    [aCoder encodeObject:_testreportid forKey:kZCProjectdetailsModelTestreportid];
    [aCoder encodeObject:_contentIdentifier forKey:kZCProjectdetailsModelId];
    [aCoder encodeObject:_sample forKey:kZCProjectdetailsModelSample];
    [aCoder encodeObject:_samnum forKey:kZCProjectdetailsModelSamnum];
    [aCoder encodeObject:_etime forKey:kZCProjectdetailsModelEtime];
    [aCoder encodeObject:_thumb forKey:kZCProjectdetailsModelThumb];
    [aCoder encodeObject:_pjname forKey:kZCProjectdetailsModelPjname];
    [aCoder encodeObject:_firstCategory forKey:kZCProjectdetailsModelFirstCategory];
    [aCoder encodeObject:_secondCategory forKey:kZCProjectdetailsModelSecondCategory];
    [aCoder encodeObject:_result forKey:kZCProjectdetailsModelResult];
    [aCoder encodeObject:_btime forKey:kZCProjectdetailsModelBtime];
    [aCoder encodeObject:_content forKey:kZCProjectdetailsModelContent];
}

- (id)copyWithZone:(NSZone *)zone
{
    ZCProjectdetailsModel *copy = [[ZCProjectdetailsModel alloc] init];
    
    if (copy) {

        copy.rank = [self.rank copyWithZone:zone];
        copy.location = [self.location copyWithZone:zone];
        copy.institutionid = [self.institutionid copyWithZone:zone];
        copy.code = [self.code copyWithZone:zone];
        copy.mid = [self.mid copyWithZone:zone];
        copy.ctime = [self.ctime copyWithZone:zone];
        copy.brand = [self.brand copyWithZone:zone];
        copy.emoney = [self.emoney copyWithZone:zone];
        copy.packageid = [self.packageid copyWithZone:zone];
        copy.pdname = [self.pdname copyWithZone:zone];
        copy.fromtype = self.fromtype;
        copy.state = [self.state copyWithZone:zone];
        copy.testreportid = [self.testreportid copyWithZone:zone];
        copy.contentIdentifier = [self.contentIdentifier copyWithZone:zone];
        copy.sample = [self.sample copyWithZone:zone];
        copy.samnum = [self.samnum copyWithZone:zone];
        copy.etime = [self.etime copyWithZone:zone];
        copy.thumb = [self.thumb copyWithZone:zone];
        copy.pjname = [self.pjname copyWithZone:zone];
        copy.firstCategory = [self.firstCategory copyWithZone:zone];
        copy.secondCategory = [self.secondCategory copyWithZone:zone];
        copy.result = [self.result copyWithZone:zone];
        copy.btime = [self.btime copyWithZone:zone];
        copy.content = [self.content copyWithZone:zone];
    }
    
    return copy;
}


@end
